package com.zzyl.nursing.mapper;


import com.zzyl.nursing.domain.Reservation;
import com.zzyl.nursing.dto.TimeSlotCountDto;
import com.zzyl.serve.domain.NursingProject;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface MemberOrdersMapper {
    @Select("select * from nursing_project")
    List<NursingProject> findAllPage();
    @Select("select * from nursing_project where id=#{id}")
    NursingProject selectById(Long id);
    @Select("select * from reservation where status = 2 and update_by = 2 and update_time between '2022-03-01' and '3022-03-31';")
    Integer countTodayCancelledReservations(@Param("userId") Long userId,
                                       @Param("startTime") LocalDateTime startTime,
                                       @Param("endTime") LocalDateTime endTime);
    @Select("select time, 6 - count(*) as count from reservation\n" +
            "  where time between '2022-03-01' and '3022-03-31' \n" +
            "    and status != 2 group by time;")
    List<TimeSlotCountDto> selectBookedCountByTime(LocalDateTime startTime, LocalDateTime endTime);

    @Insert("insert into reservation(name, mobile, time, visitor, type, status, create_time, update_time, create_by, update_by, remark) values(#{name}, #{mobile}, #{time}, #{visitor}, #{type}, #{status}, #{createTime}, #{updateTime}, #{createBy}, #{updateBy}, #{remark})")
    int insertReservation(Reservation reservation);
    @Select("select * from reservation where status = #{status} limit #{pageNum}, #{pageSize}")
    List<Reservation> findReservationPage(@Param("pageNum") Integer pageNum,
                                          @Param("pageSize") Integer pageSize,
                                          @Param("status") Integer status);
}
